<%@page import="java.util.Properties"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="org.apache.tomcat.jni.OS"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.io.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台-进行登记|银光云-为银光字幕组提供最优质的云存储服务 - Powered by 金鸡独立</title>
<%
	String user=null;
	Cookie[] cookie=request.getCookies();
	if(cookie!=null){
		for(int i=0;i<cookie.length;i++){
			if(cookie[i].getName().equals("SilverCouldUserName")==true){
				user=cookie[i].getValue();
			}
		}
	}
	if((user=="")||(user==null)){
		out.println("您还没有登陆，请进入登陆页面登陆：<br/>");
		out.println("<a href=\"index.jsp\">重新登陆</a>");
		return ;
	}
%>
</head>
<body>
<center>
<h1><font color="red">银光字幕组专属云服务后台管理系统-登记中</font></h1>
当前账户：<%=session.getAttribute("username") %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="logout.jsp">安全注销</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="main.jsp">返回主页</a><br/>
正在检查文件传递信息
<%
	request.setCharacterEncoding("UTF-8");
	String userid=(String) session.getAttribute("userid");
	String name=request.getParameter("caption");
	Date now=new Date();
	DateFormat df=DateFormat.getDateTimeInstance();
	String datetime=df.format(now);
	String detail=request.getParameter("detail");
	String count="0";
	String file=request.getParameter("filename");
	Class.forName("com.mysql.jdbc.Driver");
	Connection con=DriverManager.getConnection(application.getAttribute("dburl")+"?useUnicode=true&characterEncoding=utf8",(String) application.getAttribute("username"),(String) application.getAttribute("password"));
	File f=new File(application.getRealPath("/")+"data/"+file);
	Statement sm=con.createStatement();
	out.println("文件名："+file+"<br/>");
	if(f.exists()==false){
		out.println("你还没有上传相应文件。");
		return ;
	}
	out.println("检查成功！<br/>");
	String sql1="INSERT INTO data(userid,name,datetime,detail,hidden,count,file) VALUES("+userid+",'"+name+"','"+datetime+"','"+detail+"',FALSE,0,'"+file+"');";
	sm.executeUpdate(sql1);
	out.println("添加成功！");
	String sql2="SELECT id FROM data WHERE name='"+name+"'";
	ResultSet rs1=sm.executeQuery(sql2);
	if(rs1==null){
		out.println("致命错误-0002：无法找到添加项目，请联系QQ2276768747！");
		return ;
	}
	rs1.next();
	out.println("资源id="+rs1.getInt(1));
%>
</center>
</body>
</html>